www.gusucode.com > VC 调用控制面板各种对话框-源码程序 > VC 调用控制面板各种对话框-源码程序/code/SystemDialogs_DemoDlg.cpp
//Download by http://www.NewXing.com // SystemDialogs_DemoDlg.cpp : implementation file // #include "stdafx.h" #include "SystemDialogs_Demo.h" #include "SystemDialogs_DemoDlg.h" #include "SystemDialog.h" #ifdef _DEBUG #define new DEBUG_NEW #undef THIS_FILE static char THIS_FILE[] = __FILE__; #endif ///////////////////////////////////////////////////////////////////////////// // CSystemDialogs_DemoDlg dialog CSystemDialogs_DemoDlg::CSystemDialogs_DemoDlg(CWnd* pParent /*=NULL*/) : CDialog(CSystemDialogs_DemoDlg::IDD, pParent) { //{{AFX_DATA_INIT(CSystemDialogs_DemoDlg) // NOTE: the ClassWizard will add member initialization here //}}AFX_DATA_INIT // Note that LoadIcon does not require a subsequent DestroyIcon in Win32 m_hIcon = AfxGetApp()->LoadIcon(IDR_MAINFRAME); } void CSystemDialogs_DemoDlg::DoDataExchange(CDataExchange* pDX) { CDialog::DoDataExchange(pDX); //{{AFX_DATA_MAP(CSystemDialogs_DemoDlg) // NOTE: the ClassWizard will add DDX and DDV calls here //}}AFX_DATA_MAP } BEGIN_MESSAGE_MAP(CSystemDialogs_DemoDlg, CDialog) //{{AFX_MSG_MAP(CSystemDialogs_DemoDlg) ON_WM_PAINT() ON_WM_QUERYDRAGICON() ON_BN_CLICKED(IDC_ADD_REMOVE_PROGRAM, OnAddRemoveProgram) ON_BN_CLICKED(IDC_DATE_TIME, OnDateTime) ON_BN_CLICKED(IDC_DEVICE_MANAGER, OnDeviceManager) ON_BN_CLICKED(IDC_DISPLAY, OnDisplay) ON_BN_CLICKED(IDC_FORMAT, OnFormat) ON_BN_CLICKED(IDC_GAME_CONTROLERS, OnGameControlers) ON_BN_CLICKED(IDC_INTERNET_OPTION, OnInternetOption) ON_BN_CLICKED(IDC_KEYBOARD, OnKeyboard) ON_BN_CLICKED(IDC_MODEM, OnModem) ON_BN_CLICKED(IDC_MOUSE, OnMouse) ON_BN_CLICKED(IDC_MULTIMEDIA, OnMultimedia) ON_BN_CLICKED(IDC_NETWORK, OnNetwork) ON_BN_CLICKED(IDC_PASSWORD, OnPassword) ON_BN_CLICKED(IDC_REGIONAL_SETTINGS, OnRegionalSettings) ON_BN_CLICKED(IDC_SOUND, OnSound) ON_BN_CLICKED(IDC_SYSTEM, OnSystem) //}}AFX_MSG_MAP END_MESSAGE_MAP() ///////////////////////////////////////////////////////////////////////////// // CSystemDialogs_DemoDlg message handlers BOOL CSystemDialogs_DemoDlg::OnInitDialog() { CDialog::OnInitDialog(); // Set the icon for this dialog. The framework does this automatically // when the application's main window is not a dialog SetIcon(m_hIcon, TRUE); // Set big icon SetIcon(m_hIcon, FALSE); // Set small icon // TODO: Add extra initialization here return TRUE; // return TRUE unless you set the focus to a control } // If you add a minimize button to your dialog, you will need the code below // to draw the icon. For MFC applications using the document/view model, // this is automatically done for you by the framework. void CSystemDialogs_DemoDlg::OnPaint() { if (IsIconic()) { CPaintDC dc(this); // device context for painting SendMessage(WM_ICONERASEBKGND, (WPARAM) dc.GetSafeHdc(), 0); // Center icon in client rectangle int cxIcon = GetSystemMetrics(SM_CXICON); int cyIcon = GetSystemMetrics(SM_CYICON); CRect rect; GetClientRect(&rect); int x = (rect.Width() - cxIcon + 1) / 2; int y = (rect.Height() - cyIcon + 1) / 2; // Draw the icon dc.DrawIcon(x, y, m_hIcon); } else { CDialog::OnPaint(); } } // The system calls this to obtain the cursor to display while the user drags // the minimized window. HCURSOR CSystemDialogs_DemoDlg::OnQueryDragIcon() { return (HCURSOR) m_hIcon; } void CSystemDialogs_DemoDlg::OnAddRemoveProgram() { CSystemDialog dlg; dlg.DoModal(SD_ADD_REMOVE_PROGRAMS, m_hWnd); } void CSystemDialogs_DemoDlg::OnDateTime() { CSystemDialog dlg; dlg.DoModal(SD_DATE_TIME, m_hWnd); } void CSystemDialogs_DemoDlg::OnDeviceManager() { CSystemDialog dlg; dlg.DoModal(SD_DEVICE_MANAGER, m_hWnd); } void CSystemDialogs_DemoDlg::OnDisplay() { CSystemDialog dlg; dlg.DoModal(SD_DISPLAY, m_hWnd); } void CSystemDialogs_DemoDlg::OnFormat() { CSystemDialog dlg; dlg.DoModal(SD_FORMAT, m_hWnd); } void CSystemDialogs_DemoDlg::OnGameControlers() { CSystemDialog dlg; dlg.DoModal(SD_GAME_CONTROLLERS, m_hWnd); } void CSystemDialogs_DemoDlg::OnInternetOption() { CSystemDialog dlg; dlg.DoModal(SD_INTERNET_OPTIONS, m_hWnd); } void CSystemDialogs_DemoDlg::OnKeyboard() { CSystemDialog dlg; dlg.DoModal(SD_KEYBOARD, m_hWnd); } void CSystemDialogs_DemoDlg::OnModem() { CSystemDialog dlg; dlg.DoModal(SD_MODEM, m_hWnd); } void CSystemDialogs_DemoDlg::OnMouse() { CSystemDialog dlg; dlg.DoModal(SD_MOUSE, m_hWnd); } void CSystemDialogs_DemoDlg::OnMultimedia() { CSystemDialog dlg; dlg.DoModal(SD_MULTIMEDIA, m_hWnd); } void CSystemDialogs_DemoDlg::OnNetwork() { CSystemDialog dlg; dlg.DoModal(SD_NETWORK, m_hWnd); } void CSystemDialogs_DemoDlg::OnPassword() { CSystemDialog dlg; dlg.DoModal(SD_PASSWORD, m_hWnd); } void CSystemDialogs_DemoDlg::OnRegionalSettings() { CSystemDialog dlg; dlg.DoModal(SD_REGIONAL_SETTINGS, m_hWnd); } void CSystemDialogs_DemoDlg::OnSound() { CSystemDialog dlg; dlg.DoModal(SD_SOUNDS, m_hWnd); } void CSystemDialogs_DemoDlg::OnSystem() { CSystemDialog dlg; dlg.DoModal(SD_SYSTEM, m_hWnd); }